<layout name="Public/layout"/>
{:jumps($infos['authority'],CONTROLLER_NAME)}
        <!--主要区域开始-->
        <div id="main">
            <form action="__SELF__" method="get" id="search">
                
                <!--查询-->
                <div class="search_add">                        
                    <div>员工编号：<input type="text" class="text_search width110" value="{:I('get.no')}" name='no'/></div>                            
                    <div>姓名：<input type="text" class="width70 text_search" value="{:I('get.nickname')}" name='nickname'/></div>
                    <div>账号：<input type="text" class="width70 text_search" value="{:I('get.username')}" name='username'/></div>
                    
                    <div>
                        状态：
                        <select class="select_search" name='status' id='status'>
                            <option value="">全部</option>
                            <option value="0" <php>if( I('status')=='0' ){echo 'selected';}</php>>正常</option>
                            <option value="1" <php>if( I('status')=='1' ){echo 'selected';}</php>>禁止</option>
                        </select>
                    </div>

                    <div>
                        职位：
                        <select class="select_search" name='position_name' id='position'>
                            <option value="">全部</option>
<volist name='position' id='vo'>                               
                            <option value="{$vo.name}" <php>if( I('position_name')==$vo['name'] ){echo 'selected';}</php>
                            >{$vo.name}</option>
</volist>
                        </select>
                    </div>  
                    
                    
                    <div>
                        <input type="button" value="搜索" class="btn_search" id="btn_search" onclick="search()"/>
                    </div>
                    
                    <input type="button" value="增加" class="btn_add" onclick="location.href='__CONTROLLER__/add';" />
<!--第二行-->
<div style='margin:5px 0;'>

    <div>
                        门店：
                        <select class="select_search" name='store_name' >
                            <option value="">全部</option>
<volist name='store' id='vo'>                               
                            <option value="{$vo.name}" <php>if( I('store_name')==$vo['name'] ){echo 'selected';}</php>
                            >{$vo.name}</option>
</volist>
                        </select>
    </div>                 
  
    <div>
                        排序：
                        <select class="select_search" name='order'>
                            <option value="a.id asc" <php> if( I('get.order')=='a.id asc' ){ echo 'selected';} </php> >  ↑ 默认 </option>                        
                            <option value="a.id desc" <php> if( I('get.order')=='a.id desc' ){ echo 'selected';} </php> > ↓ 主键从高到低 </option>
                            <option value="create_time asc" <php> if( I('get.order')=='create_time asc' ){ echo 'selected';} </php> >   ↑ 日期从低到高 </option>                        
                            <option value="create_time desc" <php> if( I('get.order')=='create_time desc' ){ echo 'selected';} </php> >  ↓ 日期从高到低 </option> 
                        </select>
    </div>    
    
</div>                    
 <!--第二行结束-->                   
                    
                </div>  
 
            </form>    

                
                <!--数据区域：用表格展示数据 表格列表-->     
                <div id="data">            
                    <table id="datalist">
                        
                    <tr>
                        <th>账号ID</th>
                        <th>姓名</th>
                        <th>员工编号</th>
                        <th>账号</th>
                        <th>状态</th>
                        <th>职位</th>  
                        <th>门店</th>  
                        <th>创建日期</th>
                        <th class="width200">操作</th>
                    </tr>
<!--开始遍历数据--> 
<volist name="res['res']" id="vo" empty="$empty">                         
                    <tr>
                        <td>{$vo.id}</td>
                        <td><a href="__CONTROLLER__/detail/id/{$vo.id}">{$vo.nickname}</a></td>
                        <td>{$vo.no}</td>
                        <td>{$vo.username}</td>
                        <td>
                    <php>
                        if($vo['status']==0){
                            echo '正常';
                        }else if($vo['status']==1){
                            echo '禁止';
                        }else if($vo['status']==2){
                            echo '删除';
                        }
                    </php>
                        </td>

                        <td>
                            <a href="__CONTROLLER__/index/position_name/{$vo.position_name}/"> {$vo.position_name} </a>
                        </td>   
                        <td>{$vo.store_name}</td>
                        <td>{:date('Y-m-d',$vo['create_time'])}</td>
                        <td class="td_modi">
<if condition="$vo['status'] neq 2">                            
                            
<if condition="$vo['status'] eq 0">
   <input type="button" value="禁止"  class="btn_pause" onclick="set_status( '__CONTROLLER__/status/id/{$vo.id}/status/1' );" />
<else />
    <input type="button" value="正常"  class="btn_start" onclick="set_status( '__CONTROLLER__/status/id/{$vo.id}/status/0' );" />
</if>                                   
                                   
                            <input type="button" value="修改" class="btn_modify" onclick=" location.href='__CONTROLLER__/edit/id/{$vo.id}'; " />
                            <input type="button" value="删除" class="btn_delete" onclick=" deletes( '__CONTROLLER__/delete/id/{$vo.id}' ); " />
<else />  </if>                       
                        </td>
                    </tr>
                    
</volist>   
<!--遍历结束-->                    
                  
                </table>
                <p>操作说明：<br />
                1、创建则开通，记载创建时间；<br />
                2、禁止后，则无法登陆；<br />
                3、重新开通后，则可以正常使用；<br />
                4、删除后，标示为删除，不能再开通、修改、删除；<br />
                </div> 
                
                <!--分页-->
                <div id="pages">
                    {$res['page']}
                </div>                    
            
        </div>
        <!--主要区域结束-->


<script type="text/javascript">
    function search(){
        layer.load(2); //加载
        setTimeout(function(){
            $('#search').submit();
        },{:C('SEARCH_TIME')});
        
    }
    
    //状态
    $(function(){
        $('#status').change(function(){
            $('#search').submit();
        });
    });
    
    //职位
    $(function(){
        $('#position').change(function(){
            $('#search').submit();
        });
    });
        
     $(function(){
        $('select').change(function(){
            $('#search').submit();
        });
    });   
    
    //键盘事件    
    $(document).keydown(function(event){ 
        if(event.keyCode == 13){
//            alert(event.keyCode); 
            search();
        }            
                    
    });      
    
    
    
    //禁止 开通
    function set_status(obj){
    
        layer.confirm('你确定真的要修改用户状态吗？', {icon: 0, title:'提示'}, function(index){
        if(index){
        
                $.ajax({
                   type: "GET",
                   url: obj,
                   success: function(data){

                            //判断修改加成功！
                            if(data.status==0){
                                layer.msg(data.info,{icon: 5});
                            }else{
                                layer.msg(data.info,{icon: 6});

                                //延迟跳转
                                setTimeout(function () {
                                    location.href = "{:U('Account/index')}";
                                }, {:C('AJAX_TIME')});

                            }

                   }
                });      
        
//        layer.msg(obj);

    }  
      layer.close(index);
    });

    }
    
    
    //删除
    function deletes(obj){
      
    layer.confirm('你确定真的要删除此用户？', {icon: 3, title:'提示'}, function(index){
    if(index){    
        
        $.get(obj, function(data){
            
            //判断是否删除成功！
            if(data.status==0){
                layer.msg(data.info,{icon: 5});
            }else{
                layer.msg(data.info,{icon: 6});

                //延迟跳转
                setTimeout(function () {
                    location.href = "{:U('Account/index')}";
                }, {:C('AJAX_TIME')});

            }
            
        });
        
        
    }  
      layer.close(index);
    });    
        
    }
    
    
</script> 
<style type="text/css">
    .empty{
        font-weight:bold;
    }
</style>

<script type="text/javascript">
    $(function(){
        //点击之后的图标
         $('.emp_off').addClass('emp_on').removeClass('emp_off');
    });  
</script>